package com.woniu.sharepark.leasesystem.common.controller;


import com.woniu.sharepark.common.JsonResult;
import com.woniu.sharepark.leasesystem.common.dto.IDCardDTO;
import com.woniu.sharepark.leasesystem.common.service.IDCardService;
import com.woniu.sharepark.util.GetLoginUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @ClassName: IDCardController
 * @Description: 此类是前端传递身份证识别信息的Controller
 * @Author: Zongjie.Li
 * @Date: 2019/6/3
 * @Version: 1.0
 **/
@Controller
public class IDCardController {

    @Resource(name = "IDCardImpl")
    private IDCardService idCardService;

    @ResponseBody
    @RequestMapping("/idcardverify")
    //暂未加权限控制
    public JsonResult idCardVerify(IDCardDTO idCardDTO) throws IOException {
        return idCardService.idCardVerify(idCardDTO);
    }

    @RequestMapping("/drivingPermit")
    @ResponseBody
    public JsonResult drivingIdCard(MultipartFile file){
         JsonResult jsonResult = idCardService.drivingIdCard(file);
         return jsonResult;
    }


    @RequestMapping("/checkIdCard")
    @ResponseBody
    public JsonResult checkIdCard(){

        JsonResult jsonResult = idCardService.checkIdCardAndDriving(GetLoginUtil.getLogin().getUserInfo().getuId());
        System.out.println(jsonResult);
         return jsonResult;
    }
}
